
--[[

    slimui - Copyright (c) 2011 atom0s, All rights reserved.

    See Copyright notice in slimui.lua
    
]]--

class 'ComboBox: WinControl' { ... };

----------------------------------------------------------------------------------
-- func: ComboBox.__init__
-- desc: Constructor called when this object is first created.
----------------------------------------------------------------------------------
function ComboBox.__init__( self )
    WinControl.__init__( self );
end

----------------------------------------------------------------------------------
-- func: ComboBox:Create
-- desc: Creates a new ComboBox object.
----------------------------------------------------------------------------------
function ComboBox:Create( parent )
    if parent == nil or parent._object == nil then
        slimui:err( 'ComboBox:Create - parent must be set to create a control!' );
    end
    
    self._object = createComboBox( parent._object );
    
    if self._object == nil then
        slimui:err( 'ComboBox:Create - failed to initialize a new object.' );
    end
    
    return self;
end

----------------------------------------------------------------------------------
-- func: ComboBox:Clear
-- desc: Removes all current items from this ComboBox.
----------------------------------------------------------------------------------
function ComboBox:Clear( )
    combobox_clear( self._object );
end

----------------------------------------------------------------------------------
-- func: ComboBox:GetItems
-- desc: Returns this ComboBoxes current items.
----------------------------------------------------------------------------------
function ComboBox:GetItems( )
    return combobox_getItems( self._object );
end

----------------------------------------------------------------------------------
-- func: ComboBox:GetItemIndex
-- desc: Returns the current item index of this ComboBox.
----------------------------------------------------------------------------------
function ComboBox:GetItemIndex( )
    return combobox_getItemIndex( self._object );
end

----------------------------------------------------------------------------------
-- func: ComboBox:SetItemIndex
-- desc: Sets the current item index of this ComboBox.
----------------------------------------------------------------------------------
function ComboBox:SetItemIndex( index )
    combobox_setItemIndex( self._object, index );
end

----------------------------------------------------------------------------------
-- func: ComboBox:GetCanvas
-- desc: Returns the canvas of this ComboBox.
----------------------------------------------------------------------------------
function ComboBox:GetCanvas( )
    return combobox_getCanvas( self._object );
end



--[[ Debug information. ]]--------------------------------------------------------
if ( slimui:isdebug() == true ) then
    slimui:msg( '(Control) combobox.lua successfully loaded.' );
end